package com.yuqing.myblogServe.service.impl;

import com.github.pagehelper.PageHelper;
import com.yuqing.myblogServe.common.lang.PageBean;
import com.yuqing.myblogServe.dao.entity.ArticleComment;
import com.yuqing.myblogServe.dao.mapper.ArticleCommentMapper;
import com.yuqing.myblogServe.dao.mapper.ArticleMapper;
import com.yuqing.myblogServe.dto.ArticleCommentDto;
import com.yuqing.myblogServe.service.ArticleCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.UUID;

/**
 * @author lyq
 * @date 2023/12/9
 **/

@Service
public class ArticleCommentServiceImpl implements ArticleCommentService {
    @Autowired
    ArticleCommentMapper articleCommentMapper;

    @Autowired
    ArticleMapper articleMapper;

    @Override
    public void addArticleComment(Long userId, ArticleComment articleComment) {
        // 新增评论
        articleComment.setUserId(userId);

        articleComment.setCreateTime(LocalDateTime.now());

        articleComment.setUpdateTime(LocalDateTime.now());

        articleCommentMapper.insert(articleComment);


        // 添加评论数量+1
        articleMapper.addCommentCount(articleComment.getArticleId());


    }


}
